package ua.org.enginer.collections
{
	import mx.collections.ArrayCollection;
	
	public class UniqArrayCollection extends ArrayCollection
	{
		public var uniqField:String = "id"
		
		public function UniqArrayCollection(source:Array=null)
		{
			super(source);
		}
		
		override public function addItemAt(item:Object, index:int) : void {
			//check for same object by uniqField
			for each(var o:Object in source) {
				if (o[uniqField] == item[uniqField]) {
					trace("already in array, skip", item)
					return
				}
			}
			super.addItemAt(item, index)
		}
	}
}